package com.org.khtn.command.select;

public class Condition {
	final String className = "Condition:";
	Object para1;
	Object para2;
	String condition;

	public Condition(Object Para1, Object Para2, String Condition) {
		para1 = Para1;
		para2 = Para2;
		condition = Condition;
	}

	public Boolean eval() {
		final String methodName = "eval():";
		String typePara1 = para1.getClass().getSimpleName();
		String typePara2 = para2.getClass().getSimpleName();

		if (!typePara1.equalsIgnoreCase(typePara2))
			return false;

		switch (typePara1) {
		case "Integer":
			int tam1 = Integer.parseInt(para1.toString());
			int tam2 = Integer.parseInt(para2.toString());
			switch (condition) {
			case "=":

				return (tam1 == tam2);
			case ">":
				return (tam1 > tam2);
			case "<":
				return (tam1 < tam2);
			case ">=":
				return (tam1 >= tam2);
			case "<=":
				return (tam1 <= tam2);
			}
		case "String":
			String tam3 = para1.toString();
			String tam4 = para2.toString();
			int cmp = tam3.compareToIgnoreCase(tam4);
			switch (condition) {
			case "=":

				return cmp == 0;
			case ">":
				return cmp > 0;
			case "<":
				return cmp < 0;

			}

		}
		return true;
	}

	public static void main(String[] args) {
		Condition a = new Condition("1", "1", "=");
		System.out.println(a.eval());
	}
}
